import com.zsf.dao.UserDao;
import com.zsf.dao.UserDaoImpl;
import com.zsf.dao.UserDaoMysqlImpl;
import com.zsf.service.UserService;
import com.zsf.service.UserServiceImpl;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Mytest {
    public static void main(String[] args) {
//        //用户实际调用的是业务层，Dao层不需要接触
//        //用户实际调用的是Service通过service再调用dao层
//        UserServiceImpl userService = new UserServiceImpl();
//        userService.setUserDao(new UserDaoMysqlImpl());
//        userService.getUser();

        //获取ApplicationContext:拿到spring的容器
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");

        //容器在手，需要什么，就直接get
        UserServiceImpl userServiceImpl = (UserServiceImpl) context.getBean("UserServiceImpl");

        userServiceImpl.getUser();
    }
}
